<?php


if (!defined("EXPONENT")) exit("");
	$sermon = null;
	if (isset($_GET['id'])) {
		$sermon = $db->selectObject("sermonmodule_sermon","id=".intval($_GET['id']));
		if ($sermon != null) {
			$loc = unserialize($sermon->location_data);
		} 
	}
	
	if (exponent_permissions_check("edit",$loc) || exponent_permissions_check("administrate",$loc)) {
		$config = $db->selectObject('sermonmodule_config',"location_data='".serialize($loc)."'");
		if ($config == null) {
			$config->item_per_page=50;
			$config->doc_col=0; $config->pdf_col=0;
			$config->mp3_col=0; $config->ppt_col=0;
            $config->aggregate=array();
            $config->not_allow_post=0;
		}
		$form = sermonmodule_sermon::form($sermon, $config);
		$form->location($loc);
		$form->meta("action","save");
				
		$template = new template("sermonmodule","_form_edit",$loc);
		$template->assign("is_edit",(isset($sermon->id) ? 1 : 0));
		$template->assign("form_html",$form->toHTML());
		$template->output();
	} else {
		echo SITE_403_HTML;
	}

?>
